package com.iterator.service.web.homePage;

import com.iterator.bean.web.lc.DashBoardVO;
import com.iterator.bean.web.pojo.OrderExample;
import com.iterator.bean.web.pojo.tcy.GoodsExample;
import com.iterator.bean.web.pojo.tcy.GoodsProductExample;
import com.iterator.mapper.web.lc.DashBoardMapper;
import com.iterator.mapper.web.marketManager.OrderMapper;
import com.iterator.mapper.web.goodsManager.GoodsMapper;
import com.iterator.mapper.web.goodsManager.GoodsProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DashBoardServiceImpl implements DashBoardService{
    @Autowired
    GoodsMapper goodsMapper;
    @Autowired
    GoodsProductMapper goodsProductMapper;
    @Autowired
    OrderMapper orderMapper;
    @Autowired
    DashBoardMapper dashBoardMapper;
    @Override
    public DashBoardVO dashboard() {
        GoodsExample goodsExample = new GoodsExample();
        GoodsExample.Criteria criteria = goodsExample.createCriteria();
        criteria.andDeletedEqualTo(false);
        int goodsCount = goodsMapper.countByExample(goodsExample);
        OrderExample orderExample = new OrderExample();
        OrderExample.Criteria criteria1 = orderExample.createCriteria();
        criteria1.andDeletedEqualTo(false);
        int orderCount = orderMapper.countByExample(orderExample);
        GoodsProductExample goodsProductExample = new GoodsProductExample();
        GoodsProductExample.Criteria criteria2 = goodsProductExample.createCriteria();
        criteria2.andDeletedEqualTo(false);
        int goodsProductCount = goodsProductMapper.countByExample(goodsProductExample);
        int userCount = dashBoardMapper.count();
        return new DashBoardVO(goodsCount,userCount,goodsProductCount,orderCount);
    }
}
